package com.steven.door.utils;

import android.text.format.Time;

import java.util.Calendar;

public class TimeUtil {
    public static String getTime() {
        String time = "";
        String weekDay = "";
        try {
            Calendar calendar = Calendar.getInstance();
            //获取系统的日期
            //年
            String year = String.valueOf(calendar.get(Calendar.YEAR)) + "年";
            //月
            String month = String.valueOf(calendar.get(Calendar.MONTH) + 1) + "月";
            //日
            String day = String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)) + "日";
            //获取系统时间
            //小时
            String hour = String.valueOf(calendar.get(Calendar.HOUR_OF_DAY));
            //分钟
            String minute = String.valueOf(calendar.get(Calendar.MINUTE));
            if (hour.length() == 1) {
                hour = "0" + hour;
            }
            if (minute.length() == 1) {
                minute = "0" + minute;
            }
            time = year + month + day + "   " + hour + ":" + minute;
            int week = calendar.get(Calendar.DAY_OF_WEEK);
            switch (week) {
                case 1:
                    weekDay = "星期日";
                    break;
                case 2:
                    weekDay = "星期一";
                    break;
                case 3:
                    weekDay = "星期二";
                    break;
                case 4:
                    weekDay = "星期三";
                    break;
                case 5:
                    weekDay = "星期四";
                    break;
                case 6:
                    weekDay = "星期五";
                    break;
                case 7:
                    weekDay = "星期六";
                    break;
            }


            return time +"   " + weekDay;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
